#include <cctype>
#include <cstdio>
#include <set>
const int N = 1000005, mod = 998244353;
int n, k, ans;
int a[N];
std::set<int> smin;
std::set<int, std::greater<int>> smax;
inline int read() {
  int x = 0, ch = getchar();
  bool f = false;
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("sum.in", "r", stdin);
  freopen("sum.out", "w", stdout);
#endif
#endif
  n = read(), k = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = 1; i <= n; ++i) {
    smin.clear(), smax.clear();
    for (int j = i; j <= n; ++j) {
      smin.insert(a[j]), smax.insert(a[j]);
      if (j - i + 1 < k) continue;
      std::set<int>::iterator tmp = smin.begin();
      for (int i = 1; i < k && tmp != smin.end(); ++i) ++tmp;
      ans += *tmp, ans %= mod;
      tmp = smax.begin();
      for (int i = 1; i < k && tmp != smax.end(); ++i) ++tmp;
      ans += *tmp, ans %= mod;
    }
  }
  printf("%d", ans);
  return 0;
}